<?php
include_once "xAP-functions/webincludes.php";
echo webpageheader();
$id=intval($_GET["id"]);
?>

  <script>
  $(document).ready(function(){
    $("#leftdiv").load('event_edit_itemlist.php?id=<?=$id?>');
	$("#rightdiv").load('event_edit_help.php');
  });
  
  function AddNew(id){
  newname=$("#newbox").val();
	if(newname!='' && newname!=null){
	    $("#leftdiv").load('event_edit_itemlist.php?id=<?=$id?>&new=' + encodeURIComponent(newname));
		$("#centrediv").html("");
		$("#newbox").val("");
		$("#rightdiv").load('event_edit_help.php');
	}
  }
  function Edit(id){
  
	$("#centrediv").load('event_element.php?id=' + id);
	$("#rightdiv").load('event_edit_help.php?id=1&elid=' + id);
	
  }
  function UpdateElement(id){
	var $inputs=$('#elementform input,#elementform select');
	
	 var values = {};
	    $inputs.each(function(i, el) {
	        values[el.name] = $(el).val();
	    });

	
	$.post("event_element_update.php?id=" + id,values,
	function(data){
		$("#centrediv").html(data);
	});
	
  }
  function Delete(id){
	if(confirm('Remove Element?')){
		$("#leftdiv").load('event_edit_itemlist.php?id=<?=$id?>&delete=' + id);
		$("#centrediv").html("");
	}
  }
  function ElementFromLibrary(id,eid){
  
	$("#centrediv").load('event_element.php?id=' + id + '&set=' + eid);
	
  }
  function Settings(id){
  
	$("#centrediv").load('event_settings.php?id=' + id);
	$("#rightdiv").load('event_edit_help.php?id=2');
	
  }
  function UpdateSettings(id){
  
		var str = $("#settingsform").serialize();

	
	$.post("event_settings_update.php?id=" + id,str,
	function(data){
		$("#centrediv").html(data);
	});
	
  }
  </script>
  
<style>
#leftdiv { float: left; width:20%;}
#centrediv { float: left; width:40%;}
#rightdiv { float: right; width:40%;}
</style>
  
  
<div class='wrapper'>
<div id='leftdiv'></div>
<div id='centrediv'></div>
<div id='rightdiv'></div>
</div>


<?php
echo webpagefooter();
?>